import Vue from 'vue'
import defaultRouter from './defaultRouter';
import Router from 'vue-router';

Vue.use(Router)
const routes = [].concat(defaultRouter);
// 解决 Vue 重复点击相同路由，出现 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation 问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
}

const router = new Router({
  mode: 'hash',
  routes,
});
router.$addRoute=(params)=>{
  router.matcher=new Router({mode: 'hash',}).matcher;
  console.log(params,111);
  params.forEach(i => {
    router.addRoute('index',i);
  });
  // router.addRoute('',params);
};
export default router;
